import java.io.IOException;
import java.net.SocketException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import br.com.pentagrama.exception.PingException;
import br.com.pentagrama.service.PingICMP;
import br.com.pentagrama.service.TestadorAmbiente;
import br.com.pentagrama.service.TestadorPortas;
import br.com.pentagrama.service.dto.ResultadoPing;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws SocketException 
	 * @throws PingException 
	 */
	public static void main(String[] args) throws SocketException, IOException, PingException {
		TestadorAmbiente ta = new TestadorAmbiente();
		PingICMP ping = new PingICMP();
		
		
		System.out.println(ta.isConectavel("google.com", 80));
		ResultadoPing r = ta.getLatencia("google.com", 5);
		
		System.out.println("Media: " + r.getMedia());
		System.out.println("Mediana: " + r.getMediana());
		
		for(Long v : r.resultados) {
			System.out.println(v);
		}
		
//		try {
//			ping.ping("8.8.8.8", 1);
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}
//		
		//tp.testarConexao("google.com", 80);
		
		//System.out.println(ta.isHostValido("8.8.8.8"));
		
//		ResultadoPing latencia = ta.getLatencia("8.8.8.8", 20);
//		System.out.println(latencia.getMedia());
//		System.out.println(latencia.getMediana());

	}

}
